home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 September / SGI IRIX Patches 1995 Sep.iso / 6.0.1_patches / patchSG0000614 / patchSG0000614.idb / etc / init.d / savecore.z / savecore
Text File  |  1995-09-07  |  2KB  |  84 lines

  1. #!/sbin/sh
  2. #Tag 0x00000800
  3. #
  4. # Perform a crash dump save.
  5. # "$Revision: 1.14 $"
  6.  
  7. #
  8. # Get the crash directory from the savecore.options file (if any).
  9. #
  10. OPTIONS=`cat /etc/config/savecore.options 2> /dev/null`
  11. CRASHDIR=""
  12. if [ ! "${OPTIONS}" = "" ] ; then
  13.     for DIR in ${OPTIONS} ; do
  14.         if [ -d "${DIR}" ] ; then
  15.             CRASHDIR="${DIR}"
  16.         fi
  17.     done
  18.     if [ "${CRASHDIR}" = "" ] ; then
  19.         CRASHDIR="/var/adm/crash"
  20.         OPTIONS="${OPTIONS} ${CRASHDIR}"
  21.     fi
  22. else
  23.     OPTIONS="/var/adm/crash"
  24.     CRASHDIR=${OPTIONS}
  25. fi
  26.  
  27. #
  28. # Set the current bounds value.
  29. #
  30. BOUNDS=`cat ${CRASHDIR}/bounds 2> /dev/null`
  31. BOUNDS=${BOUNDS:=0}
  32.  
  33. #
  34. # Assign filenames appropriately for the files in ${CRASHDIR}
  35. #
  36. UNIX=${CRASHDIR}/unix.${BOUNDS}
  37. VMCORE=${CRASHDIR}/vmcore.${BOUNDS}.comp
  38. SUMMARY=${CRASHDIR}/summary.${BOUNDS}
  39. ANALYSIS=${CRASHDIR}/analysis.${BOUNDS}
  40.  
  41. CONFIG=/etc/config
  42. IS_ON=/sbin/chkconfig
  43.  
  44. if $IS_ON verbose ; then
  45.     LOGGER='lfmt -l savecore -s info'
  46. else
  47.     LOGGER='lfmt -l savecore -s info -G 1'
  48. fi
  49.  
  50. NOMSGSEVERITY=1 export NOMSGSEVERITY
  51.  
  52. #
  53. # If the savecore option is on, run 'savecore', then run an icrash
  54. # report on the core dumps saved if this is successful.
  55. # Also run savecore if /usr/bin/icrash is not found on the system.
  56. #
  57. if $IS_ON savecore || [ ! -f /usr/bin/icrash ] ; then
  58.     /usr/etc/savecore ${OPTIONS}
  59.     if [ $? -eq 0 -a -f /usr/bin/icrash ] ; then
  60.         /bin/rm -f ${SUMMARY} ${ANALYSIS}
  61.         /usr/bin/icrash -r -a ${SUMMARY} -w ${ANALYSIS} \
  62.             ${UNIX} ${VMCORE} 2> /dev/null
  63.         if [ $? -eq 0 ] ; then
  64.             ${LOGGER} "Created crash report.\n"
  65.         else
  66.             /bin/rm -f ${SUMMARY} ${ANALYSIS}
  67.         fi
  68.     fi
  69. else
  70.     if [ -f /usr/bin/icrash ] ; then
  71.         /bin/rm -f ${SUMMARY} ${ANALYSIS}
  72.         /usr/bin/icrash -c -r -a ${SUMMARY} -w ${ANALYSIS} \
  73.             /unix /dev/swap 2> /dev/null
  74.  
  75.         if [ $? -eq 0 ] ; then
  76.             ${LOGGER} "Created crash report.\n"
  77.             BOUNDS=`expr ${BOUNDS} + 1`
  78.             echo ${BOUNDS} > ${CRASHDIR}/bounds
  79.         else
  80.             /bin/rm -f ${SUMMARY} ${ANALYSIS}
  81.         fi
  82.     fi
  83. fi
  84.